<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style_xc.css" />
    <style type="text/css">
        p {
            margin-bottom: 0.5rem;
        }
        ::-webkit-input-placeholder { /* WebKit browsers */
            color:    #eaeaea;
        }
        :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color:    #eaeaea;
        }
        ::-moz-placeholder { /* Mozilla Firefox 19+ */
            color:    #eaeaea;
        }
        :-ms-input-placeholder { /* Internet Explorer 10+ */
            color:    #eaeaea;
        }
    </style>
</head>
<body class="login-bg2">
  <header class="aui-bar aui-bar-nav" id="aui-header" style="background-color:rgba(0,0,0,0) !important">
      <a class="aui-btn aui-pull-left" tapmode onClick="closeWin()">
          <span class="aui-iconfont aui-icon-left"></span>
      </a>
      <div id="title" class="aui-title">绑定邀请码</div>
  </header>


  <div class="myui-from">
    <ul class="myui-from-list">
		<li class="myui-from-list-item">
         <div class="myui-from-list-item" id="yaoqing"></div>
      </li>
      <li class="myui-from-list-item">
        <input id="yzcode" type="tel" style="display:none;" minlength="6" maxlength="6" placeholder="请输入邀请码" class="myui-from-list-item-input">
      </li>
      
      <li class="myui-from-list-item">
        <button id="btn2" type="button" style="display:none;" name="button" class="myui-from-list-item-button" onClick="toReg()">确认绑定</button>
      </li>
    </ul>
  </div>

</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
    var api_url = localStorage.getItem('api_url');
    var onoff = true;
    var code_data = '';
	var parentid = localStorage.getItem('parentid');
	if(parentid==0 || parentid==null){
	 var btn2 = document.getElementById("btn2");
		var yzcode = document.getElementById("yzcode");   
		   $api.css(btn2,'display:block');
		     $api.css(yzcode,'display:block');
	}else{
	var yaoqing = document.getElementById("yaoqing");   
		yaoqing.innerHTML = '您绑定的邀请是：'+parentid;	
	}
    apiready = function () {
      api.parseTapmode();
      var header = $api.byId('aui-header');
      $api.fixStatusBar(header);
      var headerPos = $api.offset(header);
      var body_h = $api.offset($api.dom('body')).h;

      var username = $api.byId('username');
      username.value = localStorage.getItem('user_name');

	  
	
	  
    }
    function closeWin(){
        api.closeWin({
        });
    }


    function toReg(){
     var user_id = localStorage.getItem('user_id');
     var yzcode = $api.val($api.byId('yzcode'));
   
    
     
      if(yzcode == ''){
        api.alert({
            title: '调皮~',
            msg: '请输入邀请码',
        });
        return;
      }
      api.ajax({
          url: api_url+'/login/login/yaoqingma.html',
          method: 'get',
          data: {
              values: {
                  uid:user_id,
                  parentid: yzcode
              }
          }
      },function(ret, err){
          if (ret) {
              if (ret.code == 0) {
                api.alert({
                    title: '绑定失败！',
                    msg: ret.msg,
                });
              }else {
                //localStorage.setItem('password',password);
                api.alert({
                    title: '绑定成功',
                    msg: '请返回！',
                });
                api.sendEvent({
                  name: 'outLogin',
                  extra: {
                  }
                });

                api.closeWin();
              }
          } else {
            api.alert({
                title: '糟糕~',
                msg: '网络错误！',
            });
          }
      });
    }


    function openLogin(name,password){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'login',
            url: './login.html',
            pageParam:{name:name,password:password},
        });
    }






</script>
</html>
